package cn.honqun.tinycms.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.redisson.api.RedissonClient;
import org.redisson.spring.cache.CacheConfig;
import org.redisson.spring.cache.RedissonSpringCacheManager;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RedissonConfig {
    @Bean
    CacheManager cacheManager(RedissonClient redissonClient, ObjectMapper objectMapper) {
        Map<String, CacheConfig> config = new HashMap<String, CacheConfig>();
        config.put("cacheMap", new CacheConfig(24 * 60 * 1000, 12 * 60 * 1000));

        return new RedissonSpringCacheManager(redissonClient, config);
    }
}
